package com.ruoyi.dynamic.controller.app;

import com.ruoyi.common.core.constant.constant.PathConstant;
import com.ruoyi.common.core.context.SecurityContextHolder;
import com.ruoyi.common.core.pojo.vo.BaseVO;
import com.ruoyi.common.core.pojo.vo.MultiVO;
import com.ruoyi.common.core.result.Result;
import com.ruoyi.dynamic.model.pojo.entity.RoomPaster;
import com.ruoyi.dynamic.model.pojo.request.app.AppRoomAuctionStartRequest;
import com.ruoyi.dynamic.model.pojo.request.app.AppRoomPasterAddRequest;
import com.ruoyi.dynamic.service.IRoomPasterService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;


@Tag(name = "App-房间贴纸相关", description = "App-房间贴纸相关")
@RestController
@RequestMapping(PathConstant.APP_PATH + "room-paster")
public class AppRoomPasterController {

    @Autowired
    private IRoomPasterService iRoomPasterService;


    @Operation(summary = "贴纸列表", description = "贴纸列表")
    @GetMapping
    public MultiVO<RoomPaster> listPage() {
        return Result.multi(iRoomPasterService.list());
    }

    @Operation(summary = "房间添加", description = "房间添加")
    @PostMapping("add")
    public BaseVO add(@RequestBody @Valid AppRoomPasterAddRequest request) {
        iRoomPasterService.add(request, SecurityContextHolder.getUserId());
        return Result.success();
    }

    @Operation(summary = "贴纸更新位置", description = "贴纸更新位置")
    @PostMapping("update")
    public BaseVO update(@RequestBody @Valid AppRoomPasterAddRequest request) {
        iRoomPasterService.updateLocation(request, SecurityContextHolder.getUserId());
        return Result.success();
    }


    @Operation(summary = "关闭贴纸", description = "关闭贴纸")
    @PostMapping("stop")
    public BaseVO stop(@RequestBody @Valid AppRoomAuctionStartRequest request) {
        iRoomPasterService.stop(request, SecurityContextHolder.getUserId());
        return Result.success();
    }


}
